package com.bnp.reporting.java8.date;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Set;
import java.util.function.Predicate;

/**
 * Created by adib on 12/11/14.
 */
public class LocalizedDateTimeExample {
    public static void main(String[] args) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT);
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println(dateTimeFormatter.format(localDateTime));

        ZonedDateTime gmt = ZonedDateTime.now(ZoneId.of("GMT+0"));
        ZonedDateTime Tehran = ZonedDateTime.now(ZoneId.of("GMT+03:30"));
        ZonedDateTime NY = ZonedDateTime.now(ZoneId.of("America/New_York"));
        System.out.println("GMT: " + dateTimeFormatter.format(gmt));
        System.out.println("Tehran: " + dateTimeFormatter.format(Tehran));
        System.out.println("Tehran: " + dateTimeFormatter.format(NY));

        Set<String> zones = ZoneId.getAvailableZoneIds();
        Predicate<String> condition = str -> str.contains("London");
        zones.forEach(z -> {
            if(condition.test(z))
                System.out.println(z);
        });

    }
}
